import tpl from './index.tpl';
import { trimSpaces } from '@/utils/tools';
import './index.less';

export class Search {
    constructor() {
        this.name = 'search';
        this.tpl = tpl;
    }

    searchPhone (e) {
        const $searchForm = $('#J_searchForm'),
              $searchInput = $('#J_keyword');
        
        const keyword = trimSpaces($searchInput.val()),
              action = $searchForm.prop('action'),
              keywordLen = keyword.length;
        
        if (keywordLen > 0) {
            window.open(action + '?keyword=' + keyword);
        }
    }
}